package com.finer.controller.goods;

import com.finer.dto.warehouse.GoodsTypePageDTO;
import com.finer.entity.ResponseMessage;
import com.finer.entity.document.FinerGoodsType;
import com.finer.remote.warehouse.FinerGoodsTypeRemote;
import com.finer.service.goods.WarehouseGoodsTypeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author wangenhao
 * @className WarehouseGoodsTypeController
 * @description 商品分类请求控制类
 * @date 2024-10-23 上午12:59
 **/
@RestController
@RequestMapping("/goodsType")
@Slf4j
public class WarehouseGoodsTypeController implements FinerGoodsTypeRemote {

    @Autowired
    private WarehouseGoodsTypeService warehouseGoodsTypeService;


    /**
     * @return com.finer.entity.ResponseMessage
     * @description 分页查询商品分类
     * @date 2024/10/23 上午1:21
     * @Param goodsTypePageDTO:
     **/
    @GetMapping("/page")
    public ResponseMessage getGoodsTypePage(GoodsTypePageDTO goodsTypePageDTO) {
        log.info("WarehouseGoodsTypeController getGoodsTypePage goodsTypePageDTO:{}", goodsTypePageDTO);
        ResponseMessage rs = warehouseGoodsTypeService.getGoodsTypePage(goodsTypePageDTO);
        log.info("WarehouseGoodsTypeController getGoodsTypePage rs:{}  goodsTypePageDTO:{}", rs, goodsTypePageDTO);
        return rs;
    }

    /**
     * @return com.finer.entity.ResponseMessage
     * @description 添加商品分类
     * @date 2024/10/23 上午10:32
     * @Param finerGoodsType:
     **/
    @PostMapping("/add")
    public ResponseMessage addGoodsType(@RequestBody FinerGoodsType finerGoodsType) {
        log.info("WarehouseGoodsTypeController addGoodsType finerGoodsType:{}", finerGoodsType);
        ResponseMessage rs = warehouseGoodsTypeService.addGoodsType(finerGoodsType);
        log.info("WarehouseGoodsTypeController addGoodsType rs:{}  finerGoodsType:{}", rs, finerGoodsType);
        return rs;
    }

    /**
     * @return com.finer.entity.ResponseMessage
     * @description 根据id查询商品分类
     * @date 2024/10/23 上午10:46
     * @Param id:
     **/
    @GetMapping("/{id}")
    public ResponseMessage getGoodsTypeById(@PathVariable Integer id) {
        log.info("WarehouseGoodsTypeController getGoodsTypeById id:{}", id);
        ResponseMessage rs = warehouseGoodsTypeService.getGoodsTypeById(id);
        log.info("WarehouseGoodsTypeController getGoodsTypeById rs:{}  id:{}", rs, id);
        return rs;
    }

    /**
     * @return com.finer.entity.ResponseMessage
     * @description 校验商品分类编码是否存在
     * @date 2024/10/23 下午3:36
     * @Param typeCode:
     **/
    public ResponseMessage checkGoodsTypeCode(String typeCode) {
        log.info("WarehouseGoodsTypeController checkGoodsTypeCode typeCode:{}", typeCode);
        ResponseMessage rs = warehouseGoodsTypeService.checkGoodsTypeCode(typeCode);
        log.info("WarehouseGoodsTypeController checkGoodsTypeCode rs:{}  typeCode:{}", rs, typeCode);
        return rs;
    }

    /**
     * @return com.finer.entity.ResponseMessage
     * @description 更新商品分类
     * @date 2024/10/23 上午10:56
     * @Param finerGoodsType:
     **/
    @PutMapping("/update")
    public ResponseMessage updateGoodsType(@RequestBody FinerGoodsType finerGoodsType) {
        log.info("WarehouseGoodsTypeController updateGoodsType finerGoodsType:{}", finerGoodsType);
        ResponseMessage rs = warehouseGoodsTypeService.updateGoodsType(finerGoodsType);
        log.info("WarehouseGoodsTypeController updateGoodsType rs:{}  finerGoodsType:{}", rs, finerGoodsType);
        return rs;
    }

    /**
     * @return com.finer.entity.ResponseMessage
     * @description 删除商品分类
     * @date 2024/10/23 上午11:36
     * @Param id:
     **/
    @DeleteMapping("/delete")
    public ResponseMessage deleteGoodsType(Integer id) {
        log.info("WarehouseGoodsTypeController deleteGoodsType id:{}", id);
        ResponseMessage rs = warehouseGoodsTypeService.deleteGoodsType(id);
        log.info("WarehouseGoodsTypeController deleteGoodsType rs:{}  id:{}", rs, id);
        return rs;
    }
}
